<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>首页</title>

    <!-- Bootstrap core CSS -->
    <link href="/ums/deps/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="/ums/deps/bootstrap/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/ums/style/total.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]>
    <script src="/ums/deps/bootstrap/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="/ums/deps/bootstrap/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="/ums/deps/bootstrap/js/html5shiv.min.js"></script>
    <script src="/ums/deps/bootstrap/js/respond.min.js"></script>
    <![endif]-->
    <style>
        body {
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #eee;
        }

        .form-signin {
            max-width: 330px;
            padding: 15px;
            margin: 0 auto;
        }

        .form-signin .form-signin-heading,
        .form-signin .checkbox {
            margin-bottom: 10px;
        }

        .form-signin .checkbox {
            font-weight: normal;
        }

        .form-signin .form-control {
            position: relative;
            height: auto;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding: 10px;
            font-size: 16px;
        }

        .form-signin .form-control:focus {
            z-index: 2;
        }

        .form-signin input[type="email"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }

        .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
    </style>
</head>

<body>
<div class="container">

    <div class="form-signin">
        <h2 class="form-signin-heading">欢迎登录<br/>中粮油脂采购管理系统-<br/>统一权限管理平台</h2>
        <label for="username" class="sr-only">账号</label>
        <input type="text" id="username" class="form-control" placeholder="账号" required autofocus autocomplete="off">
        <label for="password" class="sr-only">密码</label>
        <input type="password" id="password" class="form-control" placeholder="密码" required
               autocomplete="off">
        <!--<div class="checkbox">-->
        <!--<label>-->
        <!--<input type="checkbox" value="remember-me"> Remember me-->
        <!--</label>-->
        <!--</div>-->
        <button class="btn btn-lg btn-primary btn-block act_login" type="submit">登录</button>
    </div>

</div> <!-- /container -->

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/ums/deps/jquery/jquery-3.1.0.min.js"></script>
<script>window.jQuery || document.write('<script src="/ums/deps/jquery/jquery-3.1.0.min.js"><\/script>')</script>
<script src="/ums/deps/bootstrap/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/ums/deps/bootstrap/js/ie10-viewport-bug-workaround.js"></script>
<script src="/ums/deps/DataTables/datatables.min.js"></script>
<script src="/ums/deps/messenger/js/messenger.min.js"></script>
<script src="/ums/deps/messenger/js/messenger-theme-flat.js"></script>
<script src="/ums/libs/utils.js"></script>
<script src="/ums/libs/tableHelper.js"></script>
<script>
    Messenger.options = {
        extraClasses: 'messenger-fixed messenger-on-bottom messenger-on-right',
        theme: 'flat'
    };
    $(document).ready(function () {
        $(".act_login").click(function () {
            loginFunc()
        })
        $("#password").keydown(function (event) {
            if (event.which === 13) {
                loginFunc()
            }
        })
    });

    function loginFunc() {
        $.post("/ums/services/accessToken", {
            username: $("#username").val(),
            password: $("#password").val(),
            userType: 'ums'
        }, function (res) {
            console.log('res->', JSON.stringify(res));
            if (!res.access_token) {
                tableHelper.showMsg("账号或密码错误", 0)
            } else {
                localStorage.ums_access_token = res.access_token;
                localStorage.ums_real_name = res.userinfo.real_name;
                window.location.href = "/ums/pg/index.html";
            }
        })
    }
    //    utils.initOutFrame({sidebar_target: 'index'}, function () {
    //    })
</script>
</body>
</html>